import java.util.ArrayList;
import java.util.List;
public class Student {
    private final String studentId;
    private final String name;
    private final List<Course> selectedCourses;

    public Student(String studentId, String name) {
        this.studentId = studentId;
        this.name = name;
        this.selectedCourses = new ArrayList<>();
    }
    public void selectCourse(Course course) {
        if (!selectedCourses.contains(course)) {
            selectedCourses.add(course);
            System.out.println("学生 " + name + " 成功选修课程 " + course.getCourseName());
        } else {
            System.out.println("学生 " + name + " 已选修该课程 " + course.getCourseName());
        }
    }
    public void dropCourse(Course course) {
        if (selectedCourses.contains(course)) {
            selectedCourses.remove(course);
            System.out.println("学生 " + name + " 成功退选课程 " + course.getCourseName());
        } else {
            System.out.println("学生 " + name + " 未选修课程 " + course.getCourseName() + "，无法退选");
        }
    }
    public void printTimetable() {
        if (selectedCourses.isEmpty()) {
            System.out.println("学生 " + name + " 暂无选课记录");
            return;
        }
        System.out.println("学生 " + name + " 的课表：");
        for (Course course : selectedCourses) {
            System.out.println("课程编号：" + course.getCourseId() +
                    "，课程名称：" + course.getCourseName() +
                    "，上课地点：" + course.getLocation() +
                    "，时间：" + course.getTime() +
                    "，授课教师：" + course.getTeacher().getName());
        }
    }
}
